package com.epmis.epmis.controller;

import com.epmis.epmis.Service.MissionService;
import com.epmis.epmis.Service.ProjectService;
import com.epmis.epmis.pojo.Mission;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;

@Controller
public class MissionController {
    @Resource
    MissionService missionService;

    @PostMapping("/getMissionMessage")
    @ResponseBody
    public HashMap<String,Object> getMissionMessage(@RequestBody HashMap<String,Object> map){
        int id = (int) map.get("id");
        return missionService.getMissionMessage(id);
    }

    @PostMapping("/getMissionByParticipant")
    @ResponseBody
    public List<HashMap<String,Object>> getMissionByParticipant(@RequestBody HashMap<String,Object> map){
        int id = Integer.valueOf((String)map.get("id"));
        return missionService.getMissionByParticipant(id);
    }

    @PostMapping("/getMyPrincipalMissionA")
    @ResponseBody
    public PageInfo<HashMap<String,Object>> getMyPrincipalMissionA(@RequestBody HashMap<String,Object> map){
        int pageCode = (int) map.get("pageCode");
        int pageSize = (int) map.get("pageSize");
        String id = (String) map.get("id");
        return missionService.getMyPrincipalMissionA(pageCode,pageSize,id);
    }

    @PostMapping("/getMyPrincipalMissionC")
    @ResponseBody
    public PageInfo<HashMap<String,Object>> getMyPrincipalMissionC(@RequestBody HashMap<String,Object> map){
        int pageCode = (int) map.get("pageCode");
        int pageSize = (int) map.get("pageSize");
        String id = (String) map.get("id");
        return missionService.getMyPrincipalMissionC(pageCode,pageSize,id);
    }

    @PostMapping("/getMyPrincipalMissionS")
    @ResponseBody
    public PageInfo<HashMap<String,Object>> getMyPrincipalMissionS(@RequestBody HashMap<String,Object> map){
        int pageCode = (int) map.get("pageCode");
        int pageSize = (int) map.get("pageSize");
        String id = (String) map.get("id");
        String content = (String) map.get("content");
        return missionService.getMyPrincipalMissionS(pageCode,pageSize,id,content);
    }

    @PostMapping("/getHasMeMissionA")
    @ResponseBody
    public PageInfo<HashMap<String,Object>> getHasMeMissionA(@RequestBody HashMap<String,Object> map){
        int pageCode = (int) map.get("pageCode");
        int pageSize = (int) map.get("pageSize");
        String id = (String) map.get("id");
        return missionService.getHasMeMissionA(pageCode,pageSize,id);
    }

    @PostMapping("/getHasMeMissionC")
    @ResponseBody
    public PageInfo<HashMap<String,Object>> getHasMeMissionC(@RequestBody HashMap<String,Object> map){
        int pageCode = (int) map.get("pageCode");
        int pageSize = (int) map.get("pageSize");
        String id = (String) map.get("id");
        return missionService.getHasMeMissionC(pageCode,pageSize,id);
    }

    @PostMapping("/getHasMeMissionS")
    @ResponseBody
    public PageInfo<HashMap<String,Object>> getHasMeMissionS(@RequestBody HashMap<String,Object> map){
        int pageCode = (int) map.get("pageCode");
        int pageSize = (int) map.get("pageSize");
        String id = (String) map.get("id");
        String content = (String) map.get("content");
        return missionService.getHasMeMissionS(pageCode,pageSize,id,content);
    }



    @PostMapping("/getMyCreateMissionA")
    @ResponseBody
    public PageInfo<HashMap<String,Object>> getMyCreateMissionA(@RequestBody HashMap<String,Object> map){
        int pageCode = (int) map.get("pageCode");
        int pageSize = (int) map.get("pageSize");
        String id = (String) map.get("id");
        return missionService.getMyCreateMissionA(pageCode,pageSize,id);
    }

    @PostMapping("/getMyCreateMissionC")
    @ResponseBody
    public PageInfo<HashMap<String,Object>> getMyCreateMissionC(@RequestBody HashMap<String,Object> map){
        int pageCode = (int) map.get("pageCode");
        int pageSize = (int) map.get("pageSize");
        String id = (String) map.get("id");
        return missionService.getMyCreateMissionC(pageCode,pageSize,id);
    }

    @PostMapping("/getMyCreateMissionS")
    @ResponseBody
    public PageInfo<HashMap<String,Object>> getMyCreateMissionS(@RequestBody HashMap<String,Object> map){
        int pageCode = (int) map.get("pageCode");
        int pageSize = (int) map.get("pageSize");
        String id = (String) map.get("id");
        String content = (String) map.get("content");
        return missionService.getMyCreateMissionS(pageCode,pageSize,id,content);
    }

    @PostMapping("/getMyDeleteMissionA")
    @ResponseBody
    public PageInfo<HashMap<String,Object>> getMyDeleteMissionA(@RequestBody HashMap<String,Object> map){
        int pageCode = (int) map.get("pageCode");
        int pageSize = (int) map.get("pageSize");
        String id = (String) map.get("id");
        return missionService.getMyDeleteMissionA(pageCode,pageSize,id);
    }

    @PostMapping("/getMyDeleteMissionC")
    @ResponseBody
    public PageInfo<HashMap<String,Object>> getMyDeleteMissionC(@RequestBody HashMap<String,Object> map){
        int pageCode = (int) map.get("pageCode");
        int pageSize = (int) map.get("pageSize");
        String id = (String) map.get("id");
        return missionService.getMyDeleteMissionC(pageCode,pageSize,id);
    }

    @PostMapping("/getMyDeleteMissionS")
    @ResponseBody
    public PageInfo<HashMap<String,Object>> getMyDeleteMissionS(@RequestBody HashMap<String,Object> map){
        int pageCode = (int) map.get("pageCode");
        int pageSize = (int) map.get("pageSize");
        String id = (String) map.get("id");
        String content = (String) map.get("content");
        return missionService.getMyDeleteMissionS(pageCode,pageSize,id,content);
    }

    @PostMapping("/updateMissionDelete")
    @ResponseBody
    public int updateMissionDelete(@RequestBody HashMap<String,Object> map){
        return missionService.updateMissionDelete((int)map.get("id"));
    }

}
